package com.lyy.consolidate;


/**
 * @Author:  GZQ
 * @date:  2024/12/2 21:41
 * @description: 巩固练习5
 */

public class HomeWork05 {

    public static void main(String[] args) {
        new Demo().Test(); // 匿名对象
        new Demo("john").Test(); // 匿名对象
    }
}


class Test { // 父类
    String name = "Rose";
    Test() {
        System.out.println("Test"); // (1) Test
    }

    Test(String name) { // name john
        this.name = name; // 这里把父类的 name 修改 john
    }
}

class Demo extends Test { // 子类
    String name = "Jack";
    Demo() {
        super();
        System.out.println("Demo"); // (2) Demo
    }

    Demo(String s) {
        super(s);
    }

    public void Test() {
        System.out.println(super.name); // (3) Rose (5) john
        System.out.println(this.name); // (4) Jack (6) jack
    }
}
